clear
est clear

********************************************************************************
* brfss

import sasxport5 "rawdata/brfss/LLCP2011.XPT", clear
keep _state age sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 _llcpwt educa
tempfile brfss2011
sa `brfss2011', replace

import sasxport5 "rawdata/brfss/LLCP2012.XPT", clear
keep _state age sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 _llcpwt educa
tempfile brfss2012
sa `brfss2012', replace

import sasxport5 "rawdata/brfss/LLCP2013.XPT", clear
keep _state _age80 sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 _llcpwt educa
ren _age80 age
tempfile brfss2013
sa `brfss2013', replace

import sasxport5 "rawdata/brfss/LLCP2014.XPT", clear
keep _state _age80 sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 _llcpwt educa
ren _age80 age
tempfile brfss2014
sa `brfss2014', replace

import sasxport5 "rawdata/brfss/LLCP2015.XPT", clear
keep _state _age80 sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 _llcpwt educa
ren _age80 age
tempfile brfss2015
sa `brfss2015', replace

import sasxport5 "rawdata/brfss/LLCP2016.XPT", clear
keep _state _age80 sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 ecigaret ecignow _llcpwt educa
ren _age80 age
recode ecignow (1 2 =1) (3=0) (7 9 .=.), g(any_ecig)
replace any_ecig = 0 if ecigaret == 2
recode ecignow (1=1) (2 3=0) (7 9 .=.), g(daily_ecig)
replace daily_ecig = 0 if ecigaret == 2
tempfile brfss2016
sa `brfss2016', replace

import sasxport5 "rawdata/brfss/LLCP2017.XPT", clear
keep _state _age80 sex imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 ecigaret ecignow _llcpwt educa
ren _age80 age
recode ecignow (1 2 =1) (3=0) (7 9 .=.), g(any_ecig)
replace any_ecig = 0 if ecigaret == 2
recode ecignow (1=1) (2 3=0) (7 9 .=.), g(daily_ecig)
replace daily_ecig = 0 if ecigaret == 2
tempfile brfss2017
sa `brfss2017', replace

import sasxport5 "rawdata/brfss/LLCP2018.XPT", clear
keep _state _age80 sex1 imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3  ecigaret ecignow _llcpwt educa
ren _age80 age
ren sex1 sex
recode ecignow (1 2 =1) (3=0) (7 9 .=.), g(any_ecig)
replace any_ecig = 0 if ecigaret == 2
recode ecignow (1=1) (2 3=0) (7 9 .=.), g(daily_ecig)
replace daily_ecig = 0 if ecigaret == 2
tempfile brfss2018
sa `brfss2018', replace

import sasxport5 "rawdata/brfss/LLCP2019.XPT", clear
keep _state _age80 sexvar imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3 _llcpwt educa
ren _age80 age
ren sexvar sex
tempfile brfss2019
sa `brfss2019', replace

import sasxport5 "rawdata/brfss/LLCP2020.XPT", clear
keep _state _age80 sexvar imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3  ecigaret ecignow _llcpwt educa
ren _age80 age
ren sexvar sex
recode ecignow (1 2 =1) (3=0) (7 9 .=.), g(any_ecig)
replace any_ecig = 0 if ecigaret == 2
recode ecignow (1=1) (2 3=0) (7 9 .=.), g(daily_ecig)
replace daily_ecig = 0 if ecigaret == 2
tempfile brfss2020
sa `brfss2020', replace

import sasxport5 "rawdata/brfss/LLCP2021.XPT", clear
keep _state _age80 sexvar imonth iyear smoke100 smokday2 stopsmk2 lastsmk2 _smoker3 _rfsmok3  ecignow1 _llcpwt educa
ren _age80 age
ren sexvar sex
ren ecignow1 ecignow
recode ecignow (1 2=1) (3 4=0) (7 9 =.), g(any_ecig)
recode ecignow (1=1) (2 3 4=0) (7 9 =.), g(daily_ecig)
tempfile brfss2021
sa `brfss2021', replace

clear

forval y = 2011/2021 {
	app using `brfss`y''
}

ren _state fips
keep if inrange(fips, 1, 56)

destring iyear, g(year)
keep if inrange(year, 2011, 2021)
drop iyear

destring imonth, g(month)
recode month (1/3=1) (4/6=2) (7/9=3) (10/12=4), g(quarter)
drop imonth

keep if inrange(age, 18, 99)

* quit attempt in the past year (successful or not successful)
gen cig_quit_try = .
replace cig_quit_try = 0 if stopsmk2 == 2
replace cig_quit_try = 1 if stopsmk2 == 1
replace cig_quit_try = 1 if _smoker3 == 3 & inrange(lastsmk2, 1, 4)

* successful quit attempt in the past year (successful or not successful)
gen cig_quit = .
replace cig_quit = 0 if stopsmk2 == 2
replace cig_quit = 0 if stopsmk2 == 1
replace cig_quit = 1 if _smoker3 == 3 & inrange(lastsmk2, 1, 4)

* n successful quit attempt in the past year (successful or not successful)
gen cig_quit_fail = .
replace cig_quit_fail = 1 if stopsmk2 == 2
replace cig_quit_fail = 1 if stopsmk2 == 1
replace cig_quit_fail = 0 if _smoker3 == 3 & inrange(lastsmk2, 1, 4)

* currently smoke
recode smokday2 (1 2 = 1) (3=0) (7 9 .=.), g(smoke)
replace smoke = 0 if smoke100 == 2

* sex
recode sex (1=1) (2 7 9=0), g(male)
recode sex (2=1) (1 7 9=0) (7 9=.), g(female)
recode sex (7 9=1) (1 2=0), g(sex_miss)

* education
recode educ (1/3=1) (4/6 9 .=0), g(lhs)
recode educ (4=1) (1/3 5 6 9 .=0), g(hs)
recode educ (5=1) (1/4 6 9 .=0), g(scoll)
recode educ (6=1) (1/5 9 .=0), g(collg)
recode educ (9 .=1) (1/6=0), g(educ_miss)

g age_miss = 0
replace age_miss = 1 if age == .
su age, d
replace age = r(mean) if age == .

lab var lhs "Less than high school"
lab var hs "High school or GED"
lab var scoll "Some college"
lab var collg "College or more"

label var cig_quit_try "Quit attempt or sucessful quit in past 12 mo"
label var cig_quit "Sucessful quit in past 12 mo"
label var cig_quit_fail "Unsucessful quit in past 12 mo"
label var smoke "Any smoking"
label var any_ecig "Any vaping"
label var daily_ecig "Daily vaping"

label var male "Male"
label var female "Female"
label var quarter "Quarter"
label var year "Year"
label var fips "FIPS code"

keep fips year age any_ecig daily_ecig quarter cig_quit_try cig_quit cig_quit_fail smoke male female _llcpwt _smoker3 lhs hs scoll collg age_miss sex_miss educ_miss

sa "workingdata/brfss_quit_2011_2021", replace

********************************************************************************/
* county core

u "rawdata/county_core", clear

* indoor cigarette bans
g cig_ban = cig_TreatEfW_cnty/3 + cig_TreatEfR_cnty/3 + cig_TreatEfB_cnty/3
g ecig_ban = ecig_TreatEfW_cnty/3 + ecig_TreatEfR_cnty/3 + ecig_TreatEfB_cnty/3

ren state fips

g pop_vary = demo_popadult_cnty + demo_popkid_cnty

keep cig_tax_cnty ecig_taxstand2cons_y20_cty tob21_cnty econ_unemploy_cnty pop demo_popadult_cnty demo_popkid_cnty demo_povall_cnty demo_income_cnty cig_ban ecig_ban fips county year quarter demo_urban_cnty pop_vary ecig_taxlowdist_cnty ecig_min_age_cnty ecig_tax_adval_cty ecig_tax_excise_cty ecig_tax_sales_cty ecig_tax_cont_cty ecig_tax_twotier_cty

recode demo_urban_cnty (1 2=1) (3/6=0) (.=.), g(urban)
recode demo_urban_cnty (1 2=0) (3/6=1) (.=.), g(rural)

loc vars1 "cig_tax_cnty ecig_taxstand2cons_y20_cty tob21_cnty econ_unemploy_cnty demo_popadult_cnty demo_popkid_cnty demo_povall_cnty demo_income_cnty ecig_min_age_cnty"
loc vars2 "cig_tax_county ecig_tax_county tob21 uerate adults kids proverty income ecig_mlsa"
for zz in any `vars1' \ yy in any `vars2': ren zz yy

collapse (mean) cig_tax_county ecig_tax_county tob21 uerate adults kids proverty income cig_ban ecig_ban rural urban ecig_taxlowdist_cnty ecig_mlsa ecig_tax_adval_cty ecig_tax_excise_cty ecig_tax_sales_cty ecig_tax_cont_cty ecig_tax_twotier_cty (rawsum) pop_vary [aw=pop_vary] , by(fips year quarter) fast

replace ecig_mlsa = 1 if ecig_mlsa == .

* create time variable
loc nums1 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30	31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48"
loc nums2 "2010 2010 2010 2010 2011 2011 2011 2011 2012 2012 2012 2012 2013 2013 2013 2013 2014 2014 2014 2014 2015 2015 2015 2015 2016 2016 2016 2016 2017 2017 2017 2017 2018	2018 2018 2018 2019 2019 2019 2019 2020 2020 2020 2020 2021 2021 2021 2021"
loc nums3 "1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4"

g time = .
for zz in any `nums1' \ yy in any `nums2' \ xx in any `nums3': replace time = zz if year == yy & quarter == xx

* event study indicators
so fips year quarter
g eff_time = time if ecig_tax_county != 0 & ecig_tax_county[_n-1] == 0 & fips == fips[_n-1]
replace eff_time = eff_time[_n-1] if eff_time[_n-1] != . & fips == fips[_n-1]
gsort fips -time
replace eff_time = eff_time[_n-1] if eff_time[_n-1] != . & fips == fips[_n-1]
so fips time

* relative time
g rel_time = time - eff_time

* indicators -8 to +8
recode rel_time (-100/-8=1) (-7/100 .=0), g(time_m8)
recode rel_time (-7=1) (-100/-8 -6/100 .=0), g(time_m7)
recode rel_time (-6=1) (-100/-7 -5/100 .=0), g(time_m6)
recode rel_time (-5=1) (-100/-6 -4/100 .=0), g(time_m5)
recode rel_time (-4=1) (-100/-5 -3/100 .=0), g(time_m4)
recode rel_time (-3=1) (-100/-4 -2/100 .=0), g(time_m3)
recode rel_time (-2=1) (-100/-3 -1/100 .=0), g(time_m2)
recode rel_time (-1=1) (-100/-2 0/100 .=0), g(time_m1)
recode rel_time (0=1) (-100/-1 1/100 .=0), g(time_p0)
recode rel_time (1=1) (-100/0 2/100 .=0), g(time_p1)
recode rel_time (2=1) (-100/1 3/100 .=0), g(time_p2)
recode rel_time (3=1) (-100/2 4/100 .=0), g(time_p3)
recode rel_time (4=1) (-100/3 5/100 .=0), g(time_p4)
recode rel_time (5=1) (-100/4 6/100 .=0), g(time_p5)
recode rel_time (6=1) (-100/5 7/100 .=0), g(time_p6)
recode rel_time (7=1) (-100/6 8/100 .=0), g(time_p7)
recode rel_time (8/100=1) (-100/7 .=0), g(time_p8)

loc vars "time_m8 time_m7 time_m6 time_m5 time_m4 time_m3 time_m2 time_m1 time_p0 time_p1 time_p2 time_p3 time_p4 time_p5 time_p6 time_p7 time_p8"
loc labs ""-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "+1" "+2" "+3" "+4" "+5" "+6" "+7" "+8""
for zz in any `vars' \ yy in any `labs': lab var zz "yy"

egen max = max(rel_time), by(fips)
egen min = min(rel_time), by(fips)

g balance_down = 0
replace balance_down = 1 if inrange(min, -44, -8)
g balance_up = 0
replace balance_up = 1 if inrange(max, 8, 45)

drop min max
drop time

g state = "."
loc names "AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY"
loc nums "2 1 5 4 6 8 9 11 10 12 13 15 19 16 17 18 20 21 22 25 24 23 26 27 29 28 30 37 38 31 33 34 35 32 36 39 40 41 42 44 45 46 47 48 49 51 50 53 55 54 56"
for zz in any `names' \ yy in any `nums': replace state = "zz" if fips == yy

* never treated group
gen never_treat = 0
loc never "AK AL AR AZ FL HI IA ID IN MI MO MS MT ND NE OK RI SC SD TN TX"
for zz in any `never': replace never_treat = 1 if state == "zz"

* cohorts 
loc cohort "3 22 23 24 25 27 29 30 33 36 39 40 41 42 43 45"
for zz in any `cohort': g cohortzz = 0

replace cohort3 = 1 if state == "MN"
replace cohort22 = 1 if state == "NC"
replace cohort23 = 1 if (state == "LA")
replace cohort24 = 1 if state == "DC"
replace cohort27 = 1 if (state == "WV" | state == "PA")
replace cohort29 = 1 if state == "KS"
replace cohort30 = 1 if state == "CA"
replace cohort33 = 1 if state == "DE"
replace cohort36 = 1 if state == "NJ"
replace cohort39 = 1 if (state == "IL" | state == "NM" | state == "VT")
replace cohort40 = 1 if (state == "CT" | state == "NY" | state == "OH" | state == "WA" | state == "WI")
replace cohort41 = 1 if (state == "NH" | state == "ME" | state == "NV")
replace cohort42 = 1 if state == "MA"
replace cohort43 = 1 if (state == "VA" | state == "WY" | state == "KY" | state == "UT")
replace cohort45 = 1 if (state == "CO" | state == "GA" | state == "MD" | state == "OR")

tempfile county
sa `county'

********************************************************************************
* state core

u "rawdata/state_core", clear

g demo_male_st = 1 - demo_female_st

* convert the indoor vaping and smoking bans to any FULL ban
loc vars1 "cig_workplace_restrict_st cig_restaurant_restrict_st cig_bar_restrict_st ecig_workplace_restrict_st ecig_restaurant_restrict_st ecig_bar_restrict_st"
loc vars2 "cig_work_ban cig_rest_ban cig_bar_ban ecig_work_ban ecig_rest_ban ecig_bar_ban"
for zz in any `vars1' \ yy in any `vars2': recode zz (2=1) (0 1=0), g(yy)

loc names ""Cigarette ban at worksites" "Cigarette ban at bars" "Cigarette ban at restaurants" "E-cigarette ban at worksites" "E-cigarette ban at bars" "E-cigarette ban at restaurants""
for zz in any `vars2' \ yy in any `names': lab var zz "yy"

recode ecig_lic_st (0=0) (1/4=1), g(ecig_lic)
recode tob_lic_st (0=0) (1/4=1), g(tob_lic)
drop ecig_lic_st tob_lic_st

ren alc_beer_tax_st beer_tax_st
ren alc_liquor_tax_st liq_tax_st
ren state fips
ren ACA medicaid_expansion
ren econ_cpi cpi
ren econ_unemploy_st unemployrate
ren ecig_tax_excise_st ecig_tax_excise
ren ecig_tax_percent_st e_cig_percent

* recode the Medicaid coverage of the services, coverage must be full (so yes)
loc mcaid_vars "mcaid_cig_gum_ffs mcaid_cig_gum_mc mcaid_cig_lozenge_ffs mcaid_cig_lozenge_mc mcaid_cig_patch_ffs mcaid_cig_patch_mc"
for zz in any `mcaid_vars': recode zz (1=1) (0 2 3/5=0), g(zz_t)

* cover product in FFS or MC Medicaid (some states do not have both programs)
egen mcaid_gum = rowmax(mcaid_cig_gum_ffs_t mcaid_cig_gum_mc_t)
lab var mcaid_gum "Medicaid covers NRT gum in FFS or MC"
egen mcaid_loz = rowmax(mcaid_cig_lozenge_ffs_t mcaid_cig_lozenge_mc_t)
lab var mcaid_loz "Medicaid covers NRT lozenge in FFR or MC"
egen mcaid_patch= rowmax(mcaid_cig_patch_ffs_t mcaid_cig_patch_mc_t)
lab var mcaid_patch "Medicaid covers NRT patch in FFS or MC"
drop *_t

* combine the temporary and permanment e-cigarette bans into one variable
egen ban_ecigs = rowmax(ecig_tempban_st ecig_permban_st)
lab var ban_ecigs "Temporary or permanent e-cigarettte ban"

* locate first cigarette tax increase in the panel, this is now the first increase that is 50 cents or more, not defined if there was no such hike

g cig_tax_st_nom = cig_tax_st

* create a time variable

loc nums1 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48"
loc nums2 "2010 2010 2010 2010 2011 2011 2011 2011 2012 2012 2012 2012 2013 2013 2013 2013 2014 2014 2014 2014 2015 2015 2015 2015 2016 2016 2016 2016 2017 2017 2017 2017 2018	2018 2018 2018 2019 2019 2019 2019 2020 2020 2020 2020 2021 2021 2021 2021"
loc nums3 "1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4"

g time = .
for zz in any `nums1' \ yy in any `nums2' \ xx in any `nums3': replace time = zz if year == yy & quarter == xx

so fips year quarter
g dif_cig = cig_tax_st_nom - cig_tax_st_nom[_n-1] if fips == fips[_n-1]
g cig_tax_inc = 0
replace cig_tax_inc = 1 if dif_cig >= 0.50 & dif_cig != .

g test = time if cig_tax_inc == 1
egen eff_time_cig_tax = min(test), by(fips)
drop test cig_tax_inc
lab var eff_time_cig_tax "Time of first nominal state cigarette tax change of 50 cents or more (following JRU)"

* cigaratte tax increase relative time;
g rel_time_cig_tax = time-eff_time_cig_tax

recode rel_time_cig_tax (-100/-8=1) (-7/100 .=0), g(time_c_m8)
recode rel_time_cig_tax (-7=1) (-100/-8 -6/100 .=0), g(time_c_m7)
recode rel_time_cig_tax (-6=1) (-100/-7 -5/100 .=0), g(time_c_m6)
recode rel_time_cig_tax (-5=1) (-100/-6 -4/100 .=0), g(time_c_m5)
recode rel_time_cig_tax (-4=1) (-100/-5 -3/100 .=0), g(time_c_m4)
recode rel_time_cig_tax (-3=1) (-100/-4 -2/100 .=0), g(time_c_m3)
recode rel_time_cig_tax (-2=1) (-100/-3 -1/100 .=0), g(time_c_m2)
recode rel_time_cig_tax (-1=1) (-100/-2 0/100 .=0), g(time_c_m1)
recode rel_time_cig_tax (0=1) (-100/-1 1/100 .=0), g(time_c_p0)
recode rel_time_cig_tax (1=1) (-100/0 2/100 .=0), g(time_c_p1)
recode rel_time_cig_tax (2=1) (-100/1 3/100 .=0), g(time_c_p2)
recode rel_time_cig_tax (3=1) (-100/2 4/100 .=0), g(time_c_p3)
recode rel_time_cig_tax (4=1) (-100/3 5/100 .=0), g(time_c_p4)
recode rel_time_cig_tax (5=1) (-100/4 6/100 .=0), g(time_c_p5)
recode rel_time_cig_tax (6=1) (-100/5 7/100 .=0), g(time_c_p6)
recode rel_time_cig_tax (7=1) (-100/6 8/100 .=0), g(time_c_p7)
recode rel_time_cig_tax (8/100=1) (-100/7 .=0), g(time_c_p8)

loc vars "time_c_m8 time_c_m7 time_c_m6 time_c_m5 time_c_m4 time_c_m3 time_c_m2 time_c_m1 time_c_p0 time_c_p1 time_c_p2 time_c_p3 time_c_p4 time_c_p5 time_c_p6 time_c_p7 time_c_p8 "
loc labs ""-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "+1" "+2" "+3" "+4" "+5" "+6" "+7" "+8""
for zz in any `vars' \ yy in any `labs': lab var zz "yy"

egen max = max(rel_time_cig_tax), by(fips)
egen min = min(rel_time_cig_tax), by(fips)

g balance_down_cig = 0
replace balance_down_cig = 1 if inrange(min,-42,-8)
g balance_up_cig = 0
replace balance_up_cig = 1 if inrange(max,8,41)

drop min max
drop time

tempfile state
sa `state'

********************************************************************************
* merge

u "workingdata/brfss_quit_2011_2021", clear
mer m:1 fips year quarter using `county', nogen keep(3)
mer m:1 fips year quarter using `state', nogen keep(3)

* create a time variable
loc nums1 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48"
loc nums2 "2010 2010 2010 2010 2011 2011 2011 2011 2012 2012 2012 2012 2013 2013 2013 2013 2014 2014 2014 2014 2015 2015 2015 2015 2016 2016 2016 2016 2017 2017 2017 2017 2018	2018 2018 2018 2019 2019 2019 2019 2020 2020 2020 2020 2021 2021 2021 2021"
loc nums3 "1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4"

g time = .
for zz in any `nums1' \ yy in any `nums2' \ xx in any `nums3': replace time = zz if year == yy & quarter == xx

* create the full cigarette tax, sum of federal, state, and local taxes
egen cig_tax = rowtotal(cig_tax_st cig_tax_fed cig_tax_county)
lab var cig_tax "Total cigarette tax (county, state, and federal)"

* convert financial variables from nominal to real terms
su cpi if year == 2020 & quarter == 4
g base = r(mean)
g cpi20 = cpi/base

loc nom_val "cig_tax_county ecig_tax_county cig_tax_st cig_tax_fed ecig_tax_excise tob_cigar_tax_st tob_littlecigar_tax_st beer_tax cig_tax income beer_tax_st liq_tax_st"
for zz in any `nom_val': replace zz = zz/cpi20

keep if inrange(year, 2010, 2021)

su ecig_tax_county

* enactment date (for states) from CDC

***Updated 7/4/2022 by Catherine, need to double check***
g enact = 0
* California 10/31/2016
replace enact = 1 if state == "CA" & quarter == 4 & year == 2016
* Colorado 7/8/2020
replace enact = 1 if state == "CO" & quarter == 3 & year == 2020
* Connecticut 6/26/2019
replace enact = 1 if state == "CT" & quarter == 3 & year == 2019
* Delaware 7/3/2017
replace enact = 1 if state == "DE" & quarter == 3 & year == 2017
* District of Columbia 8/11/2015
replace enact = 1 if state == "DC" & quarter == 3 & year == 2015
* Georgia 7/22/2020
replace enact = 1 if state == "GA" & quarter == 3 & year == 2020
* Illinois 6/28/2019
replace enact = 1 if state == "IL" & quarter == 3 & year == 2019
* Indiana 4/29/2021
replace enact = 1 if state == "IN" & quarter == 2 & year == 2021
* Kansas 6/16/2015
replace enact = 1 if state == "KS" & quarter == 3 & year == 2015
* Kentucky 4/13/2020
replace enact = 1 if state == "KY" & quarter == 2 & year == 2020
* Louisiana 6/19/2015
replace enact = 1 if state == "LA" & quarter == 3 & year == 2015
* Maine 7/2/2019
replace enact = 1 if state == "ME" & quarter == 3 & year == 2019
* Maryland 2/12/2021
replace enact = 1 if state == "MD" & quarter == 1 & year == 2021
* Massachusetts 11/27/2019
replace enact = 1 if state == "MA" & quarter == 4 & year == 2019
* Minnesota 5/11/2010
replace enact = 1 if state == "MN" & quarter == 2 & year == 2010
* Nevada 6/12/2019
replace enact = 1 if state == "NV" & quarter == 2 & year == 2019
* New Hampshire 9/26/2019
replace enact = 1 if state == "NH" & quarter == 3 & year == 2019
* New Jersey 7/1/2018
replace enact = 1 if state == "NJ" & quarter == 3 & year == 2018
* New Mexico 4/4/2019
replace enact = 1 if state == "NM" & quarter == 2 & year == 2019
* New York 4/12/2019
replace enact = 1 if state == "NY" & quarter == 2 & year == 2019
* North Carolina 5/29/2014
replace enact = 1 if state == "NC" & quarter == 2 & year == 2014
* Ohio 7/18/2019
replace enact = 1 if state ==" OH" & quarter == 3 & year == 2019
* Oregon 11/2/2020
replace enact = 1 if state == "OR" & quarter == 4 & year == 2020
* Pennsylvania 7/13/2016
replace enact = 1 if state == "PA" & quarter == 3 & year == 2016
* Utah 3/30/2020
replace enact = 1 if state == "UT" & quarter == 2 & year == 2020
* Vermont 5/23/2019
replace enact = 1 if state == "VT" & quarter == 2 & year == 2019
* Virginia 5/21/2020
replace enact = 1 if state == "VA" & quarter == 2 & year == 2020
* Washington 5/21/2019
replace enact = 1 if state == "WA" & quarter == 2 & year == 2019
* West Virginia 6/13/2016
replace enact = 1 if state == "WV" & quarter == 2 & year == 2016
* Wisconsin 7/3/2019
replace enact = 1 if state == "WI" & quarter == 3 & year == 2019
* Wyoming 3/10/2020
replace enact = 1 if state == "WY" & quarter == 1 & year == 2020

* counties (from Mike)
* Cook Co IL 11/18/2015
replace enact = 1 if state == "CookCo" & quarter == 4 & year == 2015
* Mont Co MD 4/14/2015
replace enact = 1 if state == "MontCo" & quarter == 2 & year == 2015

so fips year quarter
replace enact = 1 if enact[_n-1] == 1 & fips == fips[_n-1] & ecig_tax_county == 0

* interact tax with distance
g ecig_taxlowdist_cnty_tax = ecig_taxlowdist_cnty*ecig_tax_county

* division-by-period FE
g div = 0
* division 1, Division 1: New England (Connecticut, Maine, Massachusetts, New Hampshire, Rhode Island, and Vermont)
replace div = 1 if inlist(state, "CT", "ME", "MA", "NH", "RI", "VT")
* division 2: Mid-Atlantic (New Jersey, New York, and Pennsylvania)
replace div = 2 if inlist(state, "NJ", "NY", "PA")
* division 3: East North Central (Illinois, Cook County, Indiana, Michigan, Ohio, and Wisconsin)
replace div = 3 if inlist(state, "IL", "CookCo", "IN", "MI", "OH", "WI")
* division 4: West North Central (Iowa, Kansas, Minnesota, Missouri, Nebraska, North Dakota, and South Dakota)
replace div = 4 if inlist(state, "IA", "KS", "MN", "MO", "NE", "ND", "SD")
* division 5: South Atlantic (Delaware, Florida, Georgia, Maryland, Montgomery County, North Carolina, South Carolina, Virginia, District of Columbia, and West Virginia)
replace div = 5 if inlist(state, "DE", "FL", "GA", "MD", "MontCo", "NC", "SC", "VA", "DC") | inlist(state, "WV")
* division 6: East South Central (Alabama, Kentucky, Mississippi, and Tennessee)
replace div = 6 if inlist(state, "AL", "KY", "MS", "TN")
* division 7: West South Central (Arkansas, Louisiana, Oklahoma, and Texas)
replace div = 7 if inlist(state, "AR", "LA", "OK", "TX")
* division 8: Mountain (Arizona, Colorado, Idaho, Montana, Nevada, New Mexico, Utah, and Wyoming)
replace div = 8 if inlist(state, "AZ", "CO", "ID", "MT", "NV", "NM", "UT", "WY")
* division 9: Pacific (Alaska, California, Hawaii, Oregon, and Washington)
replace div = 9 if inlist(state, "AK", "CA", "HI", "OR", "WA")

egen div_time = group(div time)

egen any_mcaid_cov = rowmax(mcaid_gum mcaid_loz mcaid_patch)

* population in 2010
gen temp = pop_vary if year == 2010 & quarter == 1
bysort fips: egen pop_2010q1 = max(temp)
drop temp

lab var pop_2010q1 "Jurisdiction-level population in 2010 Q1"

lab var ecig_tax_county "E-cigarette tax"

sa "workingdata/brfss_tax_clean", replace